public class Train extends Thread {
	private static int CAPACITE_TRAIN = 100;
	private static int ARRET_TRAIN = 5000;
	private static int VITESSE_TRAIN;

	private int NbDispo;
	private EspaceQuai espacequai;

	public Train(EspaceQuai espacequai) {
		setNbDispo((int) (Math.random() * CAPACITE_TRAIN));
		this.VITESSE_TRAIN = (int) (Math.random() * (300 - 50));
		this.espacequai = espacequai;
		this.setDaemon(true);
	}

	public static int getARRET_TRAIN() {
		return ARRET_TRAIN;
	}

	public static int getVITESSE_TRAIN() {
		return VITESSE_TRAIN;
	}

	public void run() {
		System.out.println("NbDispo" + NbDispo);
		espacequai.arriverTrain();
		while (espacequai.getNbEnAttente() > 0) {
			while (NbDispo > 0) {
				espacequai.faireMonter(this);
			}
		}
		espacequai.departTrain();

	}

	public int getNbDispo() {
		return NbDispo;
	}

	public void setNbDispo(int nbDispo) {
		NbDispo = nbDispo;
		try {
			//nbEnAttente++;
			System.out.println("voya attend");
			wait();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
